home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / µSim 1.0.5 / FabLibsƒ / Internet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-28  |  1.5 KB  |  73 lines  |  [TEXT/CWIE]

  1. #ifndef __ICAPI__
  2. #include <ICAPI.h>
  3. #endif
  4.  
  5. #include    "UtilsSys7.h"
  6. #include    "FabLibResIDs.h"
  7. #include    "Internet.h"
  8.  
  9. static ICError MyICLaunchURL(ICInstance inst, short STRid);
  10.  
  11. #pragma segment Main
  12.  
  13. void InternetLaunch(ICInstance inst, ICError *icErr, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct, short urlWanted)
  14. {
  15. Str31    errorStr;
  16. ICError    locICErr;
  17.  
  18. if (inst) {
  19.     *icErr = MyICLaunchURL(inst, urlWanted);
  20.     UnloadSeg(MyICLaunchURL);
  21.     }
  22. locICErr = *icErr;
  23. if (locICErr) {
  24.     switch (locICErr) {
  25.         case icPrefNotFoundErr:
  26.             (void)StopAlert_AE(kALRT_ICMISSINGHELPER, filterProc, IdleFunct);
  27.             break;
  28.         default:
  29.             NumToString(locICErr, errorStr);
  30.             ParamText(errorStr, nil, nil, nil);
  31.             (void)StopAlert_AE(kALRT_INTERNETCONFIG, filterProc, IdleFunct);
  32.         }
  33.     }
  34. }
  35.  
  36. #pragma segment Internet
  37.  
  38. ICError MyICLaunchURL(ICInstance inst, short STRid)
  39. {
  40. StringHandle    theString;
  41. long    selStart, selEnd;
  42. const short    nullstr = 0;    // otherwise IC 1.1 will crash (doesn't like odd-aligned strings)
  43. ICError    err;
  44.  
  45. if (theString = GetString(STRid)) {
  46.     selStart = 0L;
  47.     selEnd = **theString;
  48.     HLockHi((Handle) theString);
  49.     err = ICLaunchURL(inst, (ConstStr255Param)&nullstr, (Ptr)*theString + 1, selEnd, &selStart, &selEnd);
  50.     HUnlock((Handle) theString);
  51. //    UnloadSeg(ICLaunchURL);
  52.     }
  53. else
  54.     err = ResError();
  55.  
  56. return err;
  57. }
  58.  
  59. #pragma segment Init
  60.  
  61. ICError MyICInit(ICInstance *inst, OSType creator)
  62. {
  63. ICError    err;
  64.  
  65. if (err = ICStart(inst, creator))
  66.     *inst = nil;
  67. else
  68.     err = ICFindConfigFile(*inst, 0, nil);
  69. UnloadSeg(ICStart);
  70. return err;
  71. }
  72.  
  73.